/**
 * @desc check-node-types
 * @author DragonTeam <https://www.bpmport.com>
 * @since 2024/11/1 10:09
 */
import type { ExpressionNode, GatewayNode } from '@/types'

// 验证互斥网关
export function checkExclusiveGateway(node: ExpressionNode | GatewayNode) {
  if (node.type === 'gateway') {
    return node.businessData.$type === 'exclusiveGateway'
  }
  return node.$parent?.businessData.$type === 'exclusiveGateway'
}

// 验证并行网关
export function checkParallelGateway(node: ExpressionNode | GatewayNode) {
  if (node.type === 'gateway') {
    return node.businessData.$type === 'parallelGateway'
  }
  return node.$parent?.businessData.$type === 'parallelGateway'
}

// 验证默认条件
export function checkDefaultExpressionFlow(node: ExpressionNode) {
  return node.$parent?.businessData.$type === 'exclusiveGateway' && node.$parent.$default === node
}
